package com.sys.controller;

import com.dto.QueryDetail;
import com.dto.QueryPage;
import com.dto.Save;
import com.dto.sys.EmployeeDto;
import com.sys.service.EmployeeService;
import com.utils.result.Ret;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author xufan
 */
@RestController
@RequestMapping("/sys/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    /**
     *  @author: xufan
     *  @Date: 2021/7/30
     *  @Description: 员工分页查询
     */
    @GetMapping("/listPageEmployee")
    private Ret listPageEmployee(@Validated({QueryPage.class}) EmployeeDto employeeDto) {
        return employeeService.listPageEmployee(employeeDto);
    }
    /**
     *  @author: xufan
     *  @Date: 2021/7/30
     *  @Description: 根据员工id获取员工详情
     */
    @GetMapping("/getEmployeeById")
    private Ret getEmployeeById(@Validated({QueryDetail.class}) EmployeeDto employeeDto) {
        return employeeService.getEmployeeById(employeeDto);
    }
    /**
     *  @author: xufan
     *  @Date: 2021/7/30
     *  @Description: 添加员工信息
     */
    @PostMapping("/saveEmployee")
    private Ret saveEmployee(@RequestBody @Validated({Save.class}) EmployeeDto employeeDto) {
        return employeeService.saveEmployee(employeeDto);
    }
}
